extends InteractiveObject3D

@onready var mesh_instance_3d: MeshInstance3D = $MeshInstance3D

@export var isActive = false
@export var controlled_lights: Array[Light3D]

const TEST_LIGH_SWITCH_DARK = preload("res://assets/materials/test_ligh_switch/test_ligh_switch_dark.tres")
const TEST_LIGH_SWITCH_GLOWING = preload("res://assets/materials/test_ligh_switch/test_ligh_switch_glowing.tres")

func _ready() -> void:
	sync_state()

func interact(params: Dictionary = {}) -> void:
	isActive = not isActive
	sync_state()

func sync_state() -> void:
	if isActive:
		mesh_instance_3d.material_overlay = TEST_LIGH_SWITCH_DARK
		for light in controlled_lights:
			light.show()
	else:
		mesh_instance_3d.material_overlay = TEST_LIGH_SWITCH_GLOWING
		for light in controlled_lights:
			light.hide()
